#include <iostream>

using namespace std;

int v[1000];
int main(){
	int n=0,m=0;
	cin >> n;
	cin >> m;
	int f = 0;
	for(int i = 0 ; i < m ; i++){
		int a;
		int b;
		cin >> a >> b;
		if(a>b){
			v[0] = v[0];
		}
		for(int k = a ; k <= b ; k++){
			v[k] = 1;
		}
		f = 0;
		for(int j = 0 ; j <= n ; j++){
			if(v[j] == 1){
				f += 1;
			}
		}
		cout << f << endl;
	}
} 
